package studio.raptor.dispatcher.scheduler.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import studio.raptor.dispatcher.common.util.RemotingUtil;

/**
 * @author jack
 * @since 1.0
 */
@Component
@ConfigurationProperties
public class ServerConfig {

  @Value("${spring.application.name}")
  private String name;
  @Value("${server.port}")
  private int port;

  private String host = RemotingUtil.getLocalAddress();;

  private volatile boolean state = false;

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public int getPort() {
    return port;
  }

  public void setPort(int port) {
    this.port = port;
  }

  public String getHost() {

    return host;
  }

  public void setHost(String host) {
    this.host = host;
  }

  public boolean isState() {
    return state;
  }

  public void setState(boolean state) {
    this.state = state;
  }

  @Override
  public String toString() {
    return "ServerConfig{" +
        "name='" + name + '\'' +
        ", port=" + port +
        ", host='" + host + '\'' +
        ", state=" + state +
        '}';
  }
}
